home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / diskmags / 0022-3.564 / dmg-3131 / programs / rasters.s < prev    next >
Text File  |  1990-03-24  |  8KB  |  250 lines

  1. ; rasters
  2. ;
  3. ; create some nice rasters
  4. ; ST NEWS 4.3
  5. ; A Digital Insanity creation
  6.  
  7.                 clr.l   -(sp)        supervisor mode on
  8.                 move.w  #$20,-(sp)
  9.                 trap    #1
  10.                 move.l  d0,savereg
  11.                 move.l  #$70000,a7
  12.  
  13.                 move.l  #moff,-(sp)    mouse off
  14.                 clr.w   -(sp)
  15.                 move.w  #25,-(sp)
  16.                 trap    #14
  17.                 addq.l  #8,sp
  18.                 dc.w    $a00a
  19.  
  20.                 move.w  #4,-(sp)    get resolution        
  21.                 trap    #14
  22.                 addq.l  #2,sp
  23.                 move.w  d0,oldrez
  24.                 move.l  $44e,oldscr
  25.                 move.l  #$70000,screen
  26.  
  27.                 movem.l $ffff8240.w,d0-d7    set colors
  28.                 movem.l d0-d7,oldpal
  29.  
  30.                 bsr     prepare        put some graphics on screen
  31.                 bsr     hblon        enable interrupts
  32.  
  33.                 move.w  #1,-(sp)    wait for a key
  34.                 trap    #1
  35.                 addq.l  #2,sp
  36.  
  37.                 bsr     hbloff        disable interrupts
  38.  
  39.                 movem.l oldpal,d0-d7    old colors back
  40.                 movem.l d0-d7,$ffff8240.w
  41.                 move.w  oldrez,-(sp)    old resolution back
  42.                 move.l  oldscr,-(sp)
  43.                 move.l  oldscr,-(sp)
  44.                 move.w  #5,-(sp)
  45.                 trap    #14
  46.                 add.l   #12,sp
  47.  
  48.                 move.l  #mon,-(sp)    mouse on
  49.                 clr.w   -(sp)
  50.                 move.w  #25,-(sp)
  51.                 trap    #14
  52.                 addq.l  #8,sp
  53.                 dc.w    $a009
  54.  
  55.                 move.l  savereg,-(sp)    leave supervisor
  56.                 move.w  #$20,-(sp)
  57.                 trap    #1
  58.                 addq.l  #6,sp
  59.  
  60.                 clr.w   -(sp)        sayonara!
  61.                 trap    #1
  62.  
  63. oldrez:         dc.w    0
  64. oldscr:         dc.l    0
  65. savereg:        dc.l    0
  66. screen:         dc.l    0
  67. oldpal:         ds.w    16
  68. mon:            dc.b    $08
  69. moff:           dc.b    $12
  70.  
  71.                 even
  72.  
  73. ; see the article for comments about these addresses
  74. hblon:          move.l  $120,oldtb
  75.                 move.l  $70,old4
  76.                 move.l  $70,new4b+2
  77.                 move.b  $fffffa07,old07
  78.                 move.b  $fffffa09,old09
  79.                 move.b  $fffffa0f,old0f
  80.                 move.b  $fffffa11,old11
  81.                 move.b  $fffffa1b,old1b
  82.                 and.b   #$df,$fffa09
  83.                 and.b   #$fe,$fffa07 
  84.                 move.l  #newtb1,$120
  85.                 move.l  #new4,$70
  86.                 or.b    #1,$fffffa07
  87.                 or.b    #1,$fffffa13
  88.                 rts
  89.  
  90. hbloff:         move.w  sr,-(sp)
  91.                 move.w  #$2700,sr
  92.                 move.b  old07(pc),$fffffa07
  93.                 move.b  old09(pc),$fffffa09
  94.                 move.b  old0f(pc),$fffffa0f
  95.                 move.b  old11(pc),$fffffa11
  96.                 move.b  old1b(pc),$fffffa1b
  97.                 move.l  oldtb,$120
  98.                 move.l  old4,$70
  99.                 move.w  (sp)+,sr
  100.                 rts
  101.  
  102. old4:           dc.l    0
  103. oldtb:          dc.l    0
  104. old07:          dc.b    0
  105. old09:          dc.b    0
  106. old0f:          dc.b    0
  107. old11:          dc.b    0
  108. old1b:          dc.b    0
  109.  
  110.                 even
  111.  
  112. ; This is the new VBL handler
  113. new4:           clr.b   $fffffa1b.w
  114.                 move.b  #40,$fffffa21    ; first raster at line 40
  115.                 move.b  #8,$fffffa1b
  116.                 move.w  #$0,$ff8240    ; black screen
  117.                 move.l  #newtb1,$120    ; Timer B vector
  118. new4b:          jmp     $12345678
  119.  
  120. newtb1:         clr.b   $fffffa1b.w     ;timer stop
  121.                 movem.l d0-d7/a0-a1,-(sp)
  122.                 move.w  #$fa21,a1
  123.         move.b    #40,(a1)    ; second one at line 80
  124.                 move.l  #newtb2,$120
  125.                 move.b  #8,$fffffa1b.w
  126.  
  127.                 moveq.w #27,d2          ; number of colors in table
  128.                 move.l  #pal1,a0      ; pal1: color table
  129. loop            move.b  (a1),d0
  130. wait:           cmp.b   (a1),d0          ; wait one scanline
  131.                 beq     wait
  132.                 move.w  (a0)+,d1
  133.         move.w    d1,$ff8240    ; set colors
  134.         move.w    d1,$ff8242
  135.         move.w    d1,$ff8244
  136.         move.w    d1,$ff8246
  137.         move.w    d1,$ff8248
  138.         move.w    d1,$ff824a
  139.         move.w    d1,$ff824c
  140.         move.w    d1,$ff824e
  141.                 dbra    d2,loop
  142.  
  143.         movem.l    pal1,d1-d7/a0
  144. loopx        move.b    (a1),d0
  145. waitx        cmp.b    (a1),d0
  146.         beq    waitx
  147.         movem.l    d1-d7/a0,$ff8240
  148.                 
  149.                 movem.l (sp)+,d0-d7/a0-a1
  150.                 bclr    #0,$fffffa0f.w  ;end of interrupt
  151.                 rte
  152.  
  153. newtb2:         clr.b   $fffffa1b.w     ;timer stop
  154.                 movem.l d0-d7/a0-a1,-(sp)
  155.                 move.w  #$fa21,a1
  156.                 move.b  #40,(a1)    ; third one at line 120
  157.                 move.l  #newtb3,$120
  158.                 move.b  #8,$fffffa1b.w
  159.  
  160.                 move.w  #14,d1        ; raster is 14 scanlines
  161.                 move.l  #pal1,a0
  162. loop2           move.b  (a1),d0
  163. wait2           cmp.b   (a1),d0
  164.                 beq     wait2
  165.                 move.w  (a0)+,$ff8240
  166.                 dbra    d1,loop2
  167.  
  168.         movem.l    pal1,d1-d7/a0
  169.         move.b    (a1),d0
  170. waity        cmp.b    (a1),d0
  171.         beq    waity
  172.         movem.l    d1-d7/a0,$ff8240
  173.                 
  174.                 movem.l (sp)+,d0-d7/a0-a1
  175.                 bclr    #0,$fffffa0f.w  ;end of interrupt
  176.                 rte
  177.  
  178. newtb3:         clr.b   $fffffa1b.w     ;timer stop
  179.                 movem.l d0-d7/a0-a1,-(sp)
  180.                 move.w  #$fa21,a1
  181.                 move.b  #79,(a1)    ; kill border at line 199
  182.                 move.l  #killborder,$120
  183.                 move.b  #8,$fffffa1b.w
  184.  
  185.                 move.w  #14,d1
  186.                 move.l  #pal1+26,a0
  187. loop3           move.b  (a1),d0
  188. wait3           cmp.b   (a1),d0
  189.                 beq     wait3
  190.                 move.w  (a0)+,$ff8240
  191.                 dbra    d1,loop3
  192.  
  193.         movem.l    pal1,d1-d7/a0
  194.         move.b    (a1),d0
  195. waitz        cmp.b    (a1),d0
  196.         beq    waitz
  197.         movem.l    d1-d7/a0,$ff8240
  198.                 
  199.                 movem.l (sp)+,d0-d7/a0-a1
  200.                 bclr    #0,$fffffa0f.w  ;end of interrupt
  201.                 rte
  202.  
  203. killborder      clr.b   $fffffa1b.w     ;timer stop
  204.                 movem.l d0-d1/a0-a1,-(sp)
  205.                 move.w  #$fa21,a1
  206.                 move.b  #200,(a1)
  207.                 move.b  #8,$fffffa1b.w
  208.  
  209.                 move.b  (a1),d0
  210. wait4:          cmp.b   (a1),d0        ; wait last scanline
  211.                 beq     wait4        
  212.                 clr.b   $ffff820a.w     ;60 Hz
  213.                 moveq   #4,d0
  214. nopi2:          nop            ; wait a while
  215.                 dbf     d0,nopi2
  216.                 move.b  #2,$ffff820a.w  ;50 Hz
  217.                 movem.l (sp)+,d0-d1/a0-a1       
  218.                 bclr    #0,$fffffa0f.w  ;end of interrupt
  219.                 rte
  220.  
  221. ; now some routines to set the graphics
  222.  
  223. prepare:        move.w  #0,-(sp)        ;set low res
  224.                 move.l  screen(pc),-(sp)
  225.                 move.l  screen(pc),-(sp)
  226.                 move.w  #5,-(sp)
  227.                 trap    #14
  228.                 add.l   #12,sp
  229.  
  230.                 movem.l graphic(pc),d6-d7
  231.                 move.l  screen(pc),a0
  232.                 move.w  #260-1,d1       ;fill 260 scanlines
  233.  
  234. line:           moveq   #20-1,d0        ;20 planes = one scanline
  235. fill:           move.l  d6,(a0)+
  236.                 move.l  d7,(a0)+
  237.                 dbf     d0,fill
  238.                 dbf     d1,line
  239.  
  240.                 movem.l pal1(pc),d0-d3
  241.                 movem.l d0-d3,$ffff8240.w
  242.                 rts
  243.  
  244. graphic:    dc.w    $55AA,$33CC,$0FF0,$0000
  245.  
  246. pal1:           dc.w    $000,$111,$222,$333,$444,$555,$666,$777
  247.                 dc.w    $666,$555,$444,$333,$222,$111
  248.                 dc.w    $001,$002,$003,$004,$005,$006,$007
  249.                 dc.w    $006,$005,$004,$003,$002,$001,$000
  250.